home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / Samples / RAVE Starter Samples / RAVE Common Code / Common Stuff.h next >
Encoding:
C/C++ Source or Header  |  1998-04-30  |  2.4 KB  |  81 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************
  2.  
  3. Common Stuff.h
  4.  
  5. This is a standard set of includes and macros that are defined for all of the RAVE
  6. projects, including error checking code and debugging features.
  7.  
  8. Author: Timothy Carroll
  9. Apple Developer Technical Support
  10. timc@apple.com
  11.  
  12. Modification History: 
  13.  
  14. 5/1/98        TMC     Initial Release
  15.  
  16. Copyright © 1996 Apple Computer, Inc., All Rights Reserved
  17.  
  18. You may incorporate this sample code into your applications without
  19. restriction, though the sample code has been provided "AS IS" and the
  20. responsibility for its operation is 100% yours.  However, what you are
  21. not permitted to do is to redistribute the source as "DSC Sample Code"
  22. after having made changes. If you're going to re-distribute the source,
  23. we require that you make it clear in the source that the code was
  24. descended from Apple Sample Code, but that you've made changes.
  25. *************************************************************************************/
  26.  
  27. #ifndef _COMMONSTUFF_
  28. #define _COMMONSTUFF_
  29.  
  30. #pragma once
  31.  
  32. // RAVE needs enums always int to be turned on
  33. #ifdef __MWERKS__
  34.  
  35.     #if !__option (enumsalwaysint)
  36.         #error "Enums must be always int for RAVE to work properly"
  37.     #endif
  38. #endif
  39.  
  40. /*********************************************************************************
  41. #    ERROR HANDLING MACROS
  42. #
  43. #    These macros can be used to implement nice error handling within a function.
  44. #    Essentially, all errors jump to an error handler at the end of the function, which
  45. #    should cleanup  any leftovers and return the appropriate error result.
  46. #
  47. #    Note that the error handlers take a message string.  This should be a good
  48. #    indication of the actual error, and it will appear when debugging is turned on.
  49. #
  50. #    The qDebugging macro can be used to implement sanity checking code that is only
  51. #   compiled into debug builds.
  52. #
  53.     
  54.     #if qDebugging
  55.           // do additional sanity checking here.
  56.     #endif
  57. #
  58. #    This could be used to check the internal validity of an object before acting on it
  59. #    
  60. *********************************************************************************/
  61. #ifndef qDebugging
  62.     #define qDebugging 1
  63. #endif
  64.  
  65. #if qDebugging
  66.     #define SIGNAL_ERROR(msg)        {DebugStr(msg); goto error;}
  67. #else
  68.     #define SIGNAL_ERROR(msg)        {goto error;}
  69. #endif
  70.  
  71. #define FAIL_NIL(y,msg)            if (y == NULL) SIGNAL_ERROR(msg)
  72. #define FAIL_OSERR(y,msg)        if (y != noErr) SIGNAL_ERROR(msg)
  73. #define FAIL_FALSE(y,msg)        if (!y) SIGNAL_ERROR(msg)
  74.         
  75.  
  76.  
  77. #endif /* _COMMONSTUFF_ */
  78.  
  79.     
  80.  
  81.